<?php


/**
 * 邮件SMTP配置
 * Enter description here ...
 * @author Admin
 *
 */
class SmtpAction extends CommonAction{

	private $mail;   
	
	/**
	 * 初始化
	 * @see CommonAction::_initialize()
	 */
	protected function _initialize() {
		$this->_setMailer();
		
		parent::_initialize();
	}
	
	
	/**
	 * 设置邮箱SMTP
	 * Enter description here ...
	 */
	private function _setMailer(){
		import("@.ORG.SendMail"); 
		$this->mail = new SendMail();
		
		$smtp = D('smtp');
		$map['state'] = array('eq',1);   //启用状态
		$data = $smtp->where($map)->find();
		
		$this->mail->setMailer($data);
	}
	
	
	/**
	 * 发送邮件
	 * Enter description here ...
	 * @param unknown_type $address
	 * @param unknown_type $header
	 * @param unknown_type $body
	 */
	public function send($address,$header,$body){
		$config = C('SYSCONFIG');
		$header = $config['webname'].$header;  //网站名称
		
		$body = str_replace('[webname]',$config['webname'], $body);
		$body = str_replace('[website]',$config['website'], $body);
		$body = str_replace('[sina_blog]',$config['sina_blog'], $body);
		
		return $this->mail->send($address,$header,$body);
	}
	
	
}
?>